package com.example.projectcode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.projectcode.mapper.TestchoiceMapper;
import com.example.projectcode.model.Testchoice;
import com.example.projectcode.service.TestService;
import com.example.projectcode.service.TestchoiceService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestchoiceServiceImpl extends ServiceImpl<TestchoiceMapper,Testchoice> implements TestchoiceService {
    @Override
    public int addchoice(Integer testId, Integer choiceId, Integer score) {
              Testchoice testchoice = new Testchoice();
              testchoice.setChoiceId(choiceId);
              testchoice.setTestId(testId);
              testchoice.setChoiceScore(score);
        return baseMapper.insert(testchoice);
    }

    @Override
    public List<Testchoice> selectChoiceByTestId(Integer testId) {
            return baseMapper.selectList(new QueryWrapper<Testchoice>().eq("testid",testId));
    }

    @Override
    public Testchoice selecttestchoiceById(Integer testchoiceId) {
        return baseMapper.selectOne(new QueryWrapper<Testchoice>().eq("T_Cid",testchoiceId));
    }
}
